/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-11-15
 * Time: 20:21
 */
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class Pay {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //每道菜对应的价格
        int soupRicePrice = 22;//煲仔饭
        int mapoTofuPrice = 11;//麻婆豆腐
        int squirrelMandarinFishPrice = 98;//松鼠鳜鱼
        int friedDuckPrice = 60;//锅烧鸭

        //对应的数量
        int soupRiceNo = 4;
        int mapoTofuNo = 4;
        int squirrelMandarinFishNo = 1;
        int friedDuckNo = 2;

        //消费总金额
        int finalPay = (soupRicePrice*soupRiceNo+mapoTofuPrice*mapoTofuNo
                +squirrelMandarinFishPrice*squirrelMandarinFishNo+friedDuckPrice*friedDuckNo);

        System.out.println("***********  【满汉全席】消费单  ***********");
        System.out.println("编号\t\t菜品名\t\t数量\t\t金额");
        System.out.println(" 1" + "\t\t煲仔饭\t\t"   + soupRiceNo + "\t\t¥" + soupRicePrice);
        System.out.println(" 2" + "\t\t麻婆豆腐\t\t" + mapoTofuNo + "\t\t¥" + mapoTofuPrice);
        System.out.println(" 3" + "\t\t松鼠鳜鱼\t\t" + squirrelMandarinFishNo + "\t\t¥" + squirrelMandarinFishPrice);
        System.out.println(" 4" + "\t\t锅烧鸭\t\t"   + friedDuckNo + "\t\t¥" + friedDuckPrice);
        System.out.println("*****************************************");
        System.out.println("消费总金额（原价） ¥" + finalPay);
        System.out.println("用户是否为会员：是(y)/否(n)");
        String identity = sc.next();
        if(identity.equals("y")){
            TestOfMember testOfMember =new TestOfMember();
            System.out.println("请输入您的会员ID：");
            if (testOfMember.queryMember(sc.next())) {
                if(finalPay>=200){
                    finalPay*=0.7;
                }else{
                    finalPay*=0.8;
                }
                String oldstr = testOfMember.toString();
                int newpoint = finalPay;
                int oldpoint = testOfMember.getMember().getMemberIntegral();
                testOfMember.getMember().setMemberIntegral(newpoint + oldpoint);//积分修改
                String newstr = testOfMember.toString();
                testOfMember.modify(oldstr, newstr);
            }
        }else if(identity.equals("n")){
            if(finalPay>=200){
                finalPay*=0.9;
            }
        }else{
            System.out.println("输入错误！");
        }
        //找钱
        System.out.println("请输入付款金额：");
        double payment = sc.nextDouble();
        double returnMoney = payment - finalPay;
        System.out.println("实际需要支付：" + finalPay);
        System.out.println("实际付款 " + "¥" + payment);
        System.out.println("找回零钱 " + "¥" + returnMoney);
        //抽奖
        System.out.println("是否进行抽奖：是(y)/否(n)");
        String a = sc.next();
        if(a.equals("y")){
            LuckyUser.main(null);
        }
        System.out.println("**************   显示完毕   ***************");
    }
}